import Vue from "vue"
import VueRouter from "vue-router"
import Home from "../views/Home.vue"
import Me from "../views/Me"
import News from "../views/News"
// 默认找该路径下的index.vue
import Shop from "../views/shop"

Vue.use(VueRouter)

const routes = [
    {
        path: "/",
        name: "Home",
        component: Home
    },
    {
        path: "/about",
        name: "About",
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: () => import(/* webpackChunkName: "about" */ "../views/About.vue")
    },
    {
        path: "/me",
        name: "Me",
        component: Me
    },
    {
        path: "/news/:newsId",
        name: "News",
        component: News
    },
    {
        path: "/shop",
        name: "shop",
        component: Shop,
        children: [
            {
                path: "/man",
                name: "Man",
                component: () => import("../views/shop/Man")
            }, {
                path: "/woman",
                name: "Woman",
                component: () => import("../views/shop/Woman.vue")
            }
        ]
    }
]

const router = new VueRouter({
    mode: "history",
    base: process.env.BASE_URL,
    routes
})

export default router
